import asyncio
from enum import Enum

from datetime import datetime, timedelta
from pydantic import BaseModel, Field
import inspect
from typing import Optional, Callable, Any, Literal
from uuid import UUID
import time
from .full_unit_configuration import FullUnitConfiguration
from .technical_status import TechnicalStatus, TSValue
from .language_string import LanguageString
from services.control.api import ControlApi
from settings import settings
from .modem_state import ModemState
from services.services_module.schemas.configs import ModuleType

ValueType = float | int | bool | str


CURRENT_TIME_POINT = [None]

class TotalAlarmsCount(BaseModel):
    alarms_total_count: Optional[int] = 0
    warnings_total_count: Optional[int] = 0

class OldestNewestAlarmsDate(BaseModel):
    newest_date: datetime = datetime.now()
    oldest_date: datetime = datetime.now()
    alarms_total_count: int = 0

class BlockAlarmType(str, Enum):
    WARNING = 'Warning'
    ERROR = 'Alarm'

class AlarmsGroupCount(BaseModel):
    block_name: str = 'MAKIMA'
    alarm_count: int = 0,
    warning_count: Optional[int] = 0


class AlarmDescription(BaseModel):
    code: int = 0
    name: str = 'invalid'
    group: str = 'invalid'
    subgroup: Optional[str] = None
    description_en: str = 'invalid string'  # LanguageString = LanguageString()
    description_ru: str = 'invalid string'  # LanguageString = LanguageString()
    is_warning: bool = False


class Alarm(BaseModel):
    alarm_type: BlockAlarmType = BlockAlarmType.ERROR
    code: int = 0
    aid: int | None = None
    start_value: ValueType = 0
    value: ValueType = 0
    end_value: ValueType | None = None
    state: bool = False
    time: int = int(datetime.now().timestamp())
    end_time: Optional[int] = None
    serial_number: str = 'zxc1000-7b'
    device_name: str = 'NARUTO_SASKE'
    name: str = 'MAKIMA'
    group: str = 'MAKIMA'
    subgroup: Optional[str] = None
    description: str = 'invalid string'  # LanguageString = LanguageString()
    user: bool = True
    server: bool = True
    time_offset: Optional[int] = None
    end_time_offset: Optional[int] = None
    time_point: Optional[int] = None
    end_time_point: Optional[int] = None


class ServerAlarm(BaseModel):
    code: int = 0
    value: float = 0.0
    end_value: float | None = None
    state: bool = False
    time: int = datetime.now().timestamp(),
    end_time: Optional[int] = None
    block_ip: str = '10.16.0.200'
    block_name: str = 'zxc1000-7'
    uuid: str = 'd0ded0de-d0de-d0de-d0de-d0ded0ded0de'

    @staticmethod
    def from_alarm(alarm: Alarm, block_ip: str, uuid: str, alarm_db):
        alarm_time = alarm.time
        if alarm.time_point is not None:
            point_timestamp = alarm_db.get_time_point_timestamp(alarm.time_point)
            if point_timestamp is not None:
                alarm_time = point_timestamp + alarm.time_offset

        alarm_end_time = alarm.end_time
        if alarm.end_time_point is not None:
            end_point_timestamp = alarm_db.get_time_point_timestamp(alarm.end_time_point)
            if end_point_timestamp is not None:
                alarm_end_time = end_point_timestamp + alarm.end_time_offset

        return ServerAlarm(
            code=alarm.code, block_ip=block_ip,
            value=float(alarm.value), end_value=None if alarm.end_value is None else float(alarm.end_value),
            state=alarm.state,
            time=alarm_time, end_time=alarm_end_time,
            block_name=alarm.device_name,
            uuid=uuid
        )


class AlarmsContext(BaseModel):
    full_unit_configuration: FullUnitConfiguration = FullUnitConfiguration()
    technical_status: TechnicalStatus = TechnicalStatus()
    actuation_cache = [0] * settings.SERVER_INTEGRATION_ALARMS_COUNT
    startup_time: datetime = Field(default_factort=lambda: datetime.utcnow())
    is_active: bool = False

    def check_time(self, alarm_info) -> bool:
        if alarm_info.startup_timedelta is not None:
            if self.startup_time + alarm_info.startup_timedelta < datetime.utcnow():
                return False

        if alarm_info.configure_timedelta is not None:
            if self.full_unit_configuration.time + alarm_info.configure_timedelta < datetime.utcnow():
                return False

        return True

    def press_actuation_count(self, alarm_info, state: bool = False, role: Literal['adjuster', 'user', 'server'] = 'adjuster'):
        alarm_code = alarm_info.alarm_code_description.code
        if state:
            self.actuation_cache[alarm_code] += 1
        else:
            self.actuation_cache[alarm_code] = 0
            return True

        if self.actuation_cache[alarm_code] >= alarm_info.actuation_count:
            if role == 'user':
                if alarm_info.user_info is not None:
                    return self.actuation_cache[alarm_code] >= alarm_info.user_info.actuation_count

            if role == 'server':
                if alarm_info.server_info is not None:
                    return self.actuation_cache[alarm_code] >= alarm_info.server_info.actuation_count

            return True
        else:
            return False

    def update(self,
               full_unit_configuration: FullUnitConfiguration,
               technical_status: TechnicalStatus,
               ):
        self.full_unit_configuration = full_unit_configuration
        self.technical_status = technical_status

    def check(self, alarm_info, current_alarms: Alarm | None) -> Optional[Alarm]:
        self.is_active = current_alarms is not None
        alarm_code = alarm_info.alarm_code_description.code

        if alarm_code == 104:
            pass

        def new_alarm(state: bool, value):
            return Alarm(
                code=alarm_code,
                value=value,
                state=state,
                name=alarm_info.alarm_code_description.name,
                group=alarm_info.alarm_code_description.group,
                subgroup=alarm_info.alarm_code_description.subgroup,
                time=int(datetime.now().timestamp()),
                time_offset=int(time.monotonic()),
                time_point=CURRENT_TIME_POINT[0],
                serial_number=self.full_unit_configuration.unit_configuration.main_module.serial_number,
                device_name=self.full_unit_configuration.unit_configuration.block_name,
                user=alarm_info.for_all_users,
                server=alarm_info.for_all_users,
            )

        def current_or_false():
            return new_alarm(False, -0.0) if current_alarms is None else current_alarms

        if not self.check_time(alarm_info):
            self.actuation_cache[alarm_code] = 0
            return new_alarm(False, 0.0)

        if alarm_off_scams(self, alarm_code):
            self.actuation_cache[alarm_code] = 0
            return new_alarm(False, 0)

        user = alarm_info.user_info is None
        server = alarm_info.server_info is None

        enabled = True
        if alarm_info.enabled is not None:
            enabled = alarm_info.enabled(self)
            if not enabled:
                self.actuation_cache[alarm_code] = 0
                if self.is_active and alarm_info.hold:
                    return current_alarms

        if alarm_info.block_state_only is not None:
            block_state = self.full_unit_configuration.unit_configuration.unit_type == 'FSC'
            if block_state != alarm_info.block_state_only:
                self.actuation_cache[alarm_code] = 0
                return new_alarm(False, 0)

        if alarm_info.reader is None or alarm_info.bounds is None:
            if alarm_info.enabled is None or enabled:
                return current_or_false()
            else:
                self.actuation_cache[alarm_code] = 0
                return new_alarm(False, -0.0)

        ts_value = alarm_info.reader(self)
        state = alarm_info.bounds.check(self, ts_value.value)
        if enabled:
            if not state:
                self.actuation_cache[alarm_code] += 1
            else:
                self.actuation_cache[alarm_code] = 0

            if self.actuation_cache[alarm_code] >= alarm_info.actuation_count:
                ts_value.is_incorrect = True
                if alarm_info.on_alarm is not None:
                    alarm_info.on_alarm(self)

                if not user and self.actuation_cache[alarm_code] >= alarm_info.user_info.actuation_count:
                    user = True
                    ts_value.is_incorrect_user = True

                if not server and self.actuation_cache[alarm_code] >= alarm_info.user_info.actuation_count:
                    server = True
                    ts_value.is_incorrect_server = True

                return Alarm(
                    code=alarm_code,
                    value=ts_value.value,
                    state=True,
                    name=alarm_info.alarm_code_description.name,
                    group=alarm_info.alarm_code_description.group,
                    subgroup=alarm_info.alarm_code_description.subgroup,
                    time=int(datetime.now().timestamp()),
                    time_offset=int(time.monotonic()),
                    time_point=CURRENT_TIME_POINT[0],
                    serial_number=self.full_unit_configuration.unit_configuration.main_module.serial_number,
                    device_name=self.full_unit_configuration.unit_configuration.block_name,
                    user=user and alarm_info.for_all_users,
                    server=server and alarm_info.for_all_users,
                )
            else:
                return new_alarm(False, ts_value.value)

        ts_value.is_incorrect = False
        ts_value.is_incorrect_user = False
        ts_value.is_incorrect_server = False

        self.actuation_cache[alarm_code] = 0
        return new_alarm(False, ts_value.value)


class BaseBounds(BaseModel):
    def check(self, ctx: AlarmsContext, value: ValueType, only_max = False) -> bool:
        pass


class InRangeBounds(BaseBounds):
    min: ValueType | Callable[[AlarmsContext], ValueType]
    max: ValueType | Callable[[AlarmsContext], ValueType]
    offset: Optional[Callable[[AlarmsContext], ValueType]] = None

    def check(self, ctx: AlarmsContext, value: ValueType, only_max = False) -> bool:
        if callable(self.min):
            min_value = self.min(ctx)
        else:
            min_value = self.min

        if callable(self.max):
            max_value = self.max(ctx)
        else:
            max_value = self.max

        if self.offset is not None:
            offset = self.offset(ctx)
            min_value, max_value = offset + min_value, offset + max_value

        if only_max:
            return value <= max_value

        return min_value <= value <= max_value


class IncorrectInRangeBounds(BaseBounds):
    min: ValueType | Callable[[AlarmsContext], ValueType]
    max: ValueType | Callable[[AlarmsContext], ValueType]
    offset: Optional[Callable[[AlarmsContext], ValueType]] = None

    def check(self, ctx: AlarmsContext, value: ValueType, only_max = False) -> bool:
        if callable(self.min):
            min_value = self.min(ctx)
        else:
            min_value = self.min

        if callable(self.max):
            max_value = self.max(ctx)
        else:
            max_value = self.max

        if self.offset is not None:
            offset = self.offset(ctx)
            min_value, max_value = offset + min_value, offset + max_value

        return not (min_value <= value <= max_value)


class StrictBound(BaseBounds):
    value: Optional[Callable[[AlarmsContext], ValueType | TSValue]]

    def check(self, ctx: AlarmsContext, value: ValueType, only_max = False) -> bool:
        return value == self.value(ctx)


class InvStrictBound(BaseBounds):
    value: Optional[Callable[[AlarmsContext], ValueType | TSValue]]

    def check(self, ctx: AlarmsContext, value: ValueType, only_max = False) -> bool:
        return value != self.value(ctx)


class UserAlarmInfo(BaseModel):
    actuation_count: int = 1

class ServerAlarmInfo(BaseModel):
    actuation_count: int = 1

class AlarmInfo(BaseModel):
    alarm_code_description: AlarmDescription
    bounds: Optional[BaseBounds] = None
    block_state_only: Optional[bool] = None
    actuation_count: int = 1
    reader: Optional[Callable[[AlarmsContext], ValueType | TSValue]] = None
    enabled: Optional[Callable[[AlarmsContext], bool]] = None
    on_alarm: Optional[Callable[[AlarmsContext], Any]] = None
    hold: bool = False
    startup_timedelta: Optional[timedelta] = None
    configure_timedelta: Optional[datetime] = None
    user_info: Optional[UserAlarmInfo] = None
    server_info: Optional[ServerAlarmInfo] = None
    for_all_users: bool = True


def _off_service(ctx: AlarmsContext, index: int):
    async def back_on():
        control_api = ControlApi()
        await control_api.set_control_state(f'service_{index}_state', False)

        await asyncio.sleep(133)
        
        if ctx.full_unit_configuration.service_channels[index].str.enabled:
            await control_api.set_control_state(f'service_{index}_state', True)

    asyncio.create_task(back_on())


ALARMS = [
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=0, name='RTR1InputPilotPower',
            group='RM', subgroup='RM1',
            description_en='The pilot-signal power level has gone beyond permissible limits in the relay channel 1',
            description_ru='Уровень принимаемой мощности пилот-сигнала вышел за допустимые пределы в радиоканале 1',
        ),
        block_state_only=True,
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=42.0-2, max=42.0+2),
        actuation_count=48,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].pilots_power_rx,

    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=1, name='RTR2InputPilotPower',
            group='RM', subgroup='RM2',
            description_en='The pilot-signal power level has gone beyond permissible limits in the relay channel 2',
            description_ru='Уровень принимаемой мощности пилот-сигнала вышел за допустимые пределы в радиоканале 2',
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=42.0-2, max=42.0+2),
        actuation_count=48,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].pilots_power_rx,
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=2, name='RTR1OutputPower',
            group='RM', subgroup='RM1',
            description_en='The pilot-signal output power level has gone beyond permissible limits in the relay channel 1',
            description_ru='Уровень передаваемой мощности пилот-сигнала вышел за допустимые пределы в радиоканале 1'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_tx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        actuation_count=9,
        startup_timedelta=timedelta(minutes=3.1),
        user_info=UserAlarmInfo(actuation_count=56),
        server_info=ServerAlarmInfo(actuation_count=66)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=3, name='RTR2OutputPower',
            group='RM', subgroup='RM2',
            description_en='The pilot-signal output power level has gone beyond permissible limits in the relay channel 2',
            description_ru='Уровень передаваемой мощности пилот-сигнала вышел за допустимые пределы в радиоканале 2'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_tx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        actuation_count=9,
        startup_timedelta=timedelta(minutes=3.1),
        user_info=UserAlarmInfo(actuation_count=56),
        server_info=ServerAlarmInfo(actuation_count=66)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=4, name='RTR1VSWR',
            group='RM', subgroup='RM1',
            description_en='VSWR has exceed in the relay channel 1',
            description_ru='КСВ превышен в радиоканале 1'
        ),
        # enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        # bounds=IncorrectInRangeBounds(min=0.56, max=0.65),
        # reader=lambda ctx: ctx.technical_status.rm_telemetry[0].rf_rev_detector_out
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=5, name='RTR1VSWRCritical',
            group='RM', subgroup='RM1',
            description_en='VSWR is critical in the relay channel 1',
            description_ru='Значение КСВ критическое в радиоканале 1'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        enabled=lambda ctx:
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(
            min=lambda ctx: ctx.technical_status.rm_telemetry[0].rtr_normal_vswr.value * 0.8,
            max=lambda ctx: ctx.technical_status.rm_telemetry[0].rtr_normal_vswr.value * 4.0
        ),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].rf_rev_detector_out
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=6, name='RTR2VSWR',
            group='RM', subgroup='RM2',
            description_en='VSWR has exceed in the relay channel 2',
            description_ru='КСВ превышен в радиоканале 2'
        ),
        # enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        # bounds=IncorrectInRangeBounds(min=0.56, max=0.65),
        # reader=lambda ctx: ctx.technical_status.rm_telemetry[1].rf_rev_detector_out
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=7, name='RTR2VSWRCritical',
            group='RM', subgroup='RM2',
            description_en='VSWR is critical in the relay channel 2',
            description_ru='Значение КСВ критическое в радиоканале 2'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(
            min=lambda ctx: ctx.technical_status.rm_telemetry[1].rtr_normal_vswr.value * 0.8,
            max=lambda ctx: ctx.technical_status.rm_telemetry[1].rtr_normal_vswr.value * 4.0
        ),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].rf_rev_detector_out
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=8, name='STR1InputPower',
            group='SM', subgroup='SM1',
            description_en='Expected power level has exceed in the service channel 1',
            description_ru='Превышение ожидаемой мощности от БС в сервисном канале 1'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value and
            any([
                ctx.full_unit_configuration.unit_configuration.ac_link_tx,
                ctx.full_unit_configuration.unit_configuration.ac_link_rx
            ]),
        bounds=InRangeBounds(
            min=-99.0, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.output_power
        ),
        block_state_only=True,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].base_station_current_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=9, name='STR2InputPower',
            group='SM', subgroup='SM2',
            description_en='Expected power level has exceed in the service channel 2',
            description_ru='Превышение ожидаемой мощности от БС в сервисном канале 2'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value and
            any([
                ctx.full_unit_configuration.unit_configuration.ac_link_tx,
                ctx.full_unit_configuration.unit_configuration.ac_link_rx
            ]),
        bounds=InRangeBounds(
            min=-99.0, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.output_power
        ),
        block_state_only=True,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].base_station_current_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=10, name='STR3InputPower',
            group='SM', subgroup='SM3',
            description_en='Expected power level has exceed in the service channel 3',
            description_ru='Превышение ожидаемой мощности от БС в сервисном канале 3'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value and
            any([
                ctx.full_unit_configuration.unit_configuration.ac_link_tx,
                ctx.full_unit_configuration.unit_configuration.ac_link_rx
            ]),
        bounds=InRangeBounds(
            min=-99.0, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.output_power
        ),
        block_state_only=True,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].base_station_current_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=11, name='STR4InputPower',
            group='SM', subgroup='SM4',
            description_en='Expected power level has exceed in the service channel 4',
            description_ru='Превышение ожидаемой мощности от БС в сервисном канале 4'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value and
            any([
                ctx.full_unit_configuration.unit_configuration.ac_link_tx,
                ctx.full_unit_configuration.unit_configuration.ac_link_rx
            ]),
        bounds=InRangeBounds(
            min=-99.0, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.output_power
        ),
        block_state_only=True,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].base_station_current_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=12, name='STR1OutputPower',
            group='SM', subgroup='SM1',
            description_en='Output power level has exceed in the service channel 1',
            description_ru='Превышение выходной мощности в сервисном канале 1'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value and
            ctx.full_unit_configuration.unit_configuration.ac_service_tx,
        bounds=InRangeBounds(
            min=-99, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.output_power
        ),
        block_state_only=False,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].sm_output_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=13, name='STR2OutputPower',
            group='SM', subgroup='SM2',
            description_en='Output power level has exceed in the service channel 2',
            description_ru='Превышение выходной мощности в сервисном канале 2'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value and
            ctx.full_unit_configuration.unit_configuration.ac_service_tx,
        bounds=InRangeBounds(
            min=-99, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.output_power
        ),
        block_state_only=False,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].sm_output_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=14, name='STR3OutputPower',
            group='SM', subgroup='SM3',
            description_en='Output power level has exceed in the service channel 3',
            description_ru='Превышение выходной мощности в сервисном канале 3'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value and
            ctx.full_unit_configuration.unit_configuration.ac_service_tx,
        bounds=InRangeBounds(
            min=-99, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.output_power
        ),
        block_state_only=False,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].sm_output_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=15, name='STR4OutputPower',
            group='SM', subgroup='SM4',
            description_en='Output power level has exceed in the service channel 4',
            description_ru='Превышение выходной мощности в сервисном канале 4'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value and
            ctx.full_unit_configuration.unit_configuration.ac_service_tx,
        bounds=InRangeBounds(
            min=-99.0, max=3.0,
            offset=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.output_power
        ),
        block_state_only=False,
        actuation_count=8,
        user_info=UserAlarmInfo(actuation_count=28),
        server_info=ServerAlarmInfo(actuation_count=48),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].sm_output_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=16, name='STR1VSWR',
            group='SM', subgroup='SM1',
            description_en='VSWR has exceed in the service channel 1',
            description_ru='КСВ превышен в сервисном канале 1'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value,
        bounds=IncorrectInRangeBounds(min=1.06, max=1.15),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].reflected_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=17, name='STR1VSWRCritical',
            group='SM', subgroup='SM1',
            description_en='VSWR is critical in the service channel 1',
            description_ru='Значение КСВ критическое в сервисном канале 1'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value and
            ctx.technical_status.sm_telemetry[0].voltage_28v.value > 0.0 and
            ctx.technical_status.sm_telemetry[0].lna_5v.value > 0.0,
        bounds=IncorrectInRangeBounds(min=0, max=1.059),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].reflected_power,
        on_alarm=lambda ctx: _off_service(ctx, 0),
        hold=True
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=18, name='STR2VSWR',
            group='SM', subgroup='SM2',
            description_en='VSWR has exceed in the service channel 2',
            description_ru='КСВ превышен в сервисном канале 2'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        bounds=IncorrectInRangeBounds(min=1.06, max=1.15),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].reflected_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=19, name='STR2VSWRCritical',
            group='SM', subgroup='SM2',
            description_en='VSWR is critical in the service channel 2',
            description_ru='Значение КСВ критическое в сервисном канале 2'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value and
            ctx.technical_status.sm_telemetry[1].voltage_28v.value > 0.0 and
            ctx.technical_status.sm_telemetry[1].lna_5v.value > 0.0,
        bounds=IncorrectInRangeBounds(min=0, max=1.059),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].reflected_power,
        on_alarm=lambda ctx: _off_service(ctx, 1),
        hold=True
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=20, name='STR3VSWR',
            group='SM', subgroup='SM3',
            description_en='VSWR has exceed in the service channel 3',
            description_ru='КСВ превышен в сервисном канале 3'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value,
        bounds=IncorrectInRangeBounds(min=1.06, max=1.15),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].reflected_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=21, name='STR3VSWRCritical',
            group='SM', subgroup='SM3',
            description_en='VSWR is critical in the service channel 3',
            description_ru='Значение КСВ критическое в сервисном канале 3'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value and
            ctx.technical_status.sm_telemetry[2].voltage_28v.value > 0.0 and
            ctx.technical_status.sm_telemetry[2].lna_5v.value > 0.0,
        bounds=IncorrectInRangeBounds(min=0, max=1.059),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].reflected_power,
        on_alarm=lambda ctx: _off_service(ctx, 2),
        hold=True
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=22, name='STR4VSWR',
            group='SM', subgroup='SM4',
            description_en='VSWR has exceed in the service channel 4',
            description_ru='КСВ превышен в сервисном канале 4'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value,
        bounds=IncorrectInRangeBounds(min=1.06, max=1.15),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].reflected_power
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=23, name='STR4VSWRCritical',
            group='SM', subgroup='SM4',
            description_en='VSWR is critical in the service channel 4',
            description_ru='Значение КСВ критическое в сервисном канале 4'
        ),
        actuation_count=11,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
        block_state_only=False,
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value and
            ctx.technical_status.sm_telemetry[3].voltage_28v.value > 0.0 and
            ctx.technical_status.sm_telemetry[3].lna_5v.value > 0.0,
        bounds=IncorrectInRangeBounds(min=0, max=1.059),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].reflected_power,
        on_alarm=lambda ctx: _off_service(ctx, 3),
        hold=True
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=24, name='RTR1AD9361Status',
            group='DSP',
            description_en='Connection to AD9361 – 1 RadioLink is lost',
            description_ru='Нарушение работоспособности AD9361 – 1 Радиолинк'
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_1
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=25, name='STR2AD9361Status',
            group='DSP',
            description_en='Connection to AD9361 – 2 Service channels 1 and 2 is lost',
            description_ru='Нарушение работоспособности AD9361 – 2 Сервисный канал 1 и 2'
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_2
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=26, name='STR3AD9361Status',
            group='DSP',
            description_en='Connection to AD9361 – 3 Service channels 3 and 4 is lost',
            description_ru='Нарушение работоспособности AD9361 – 3 Сервисный канал 3 и 4'
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_3
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=27, name='TR4AD9364Status',
            group='DSP',
            description_en='Connection to AD9364 – Power meters is lost',
            description_ru='Нарушение работоспособности AD9364 — Измеритель мощностей'
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.statuses.ad9364_4
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=28, name='RTR1OverCurrent',
            group='RM', subgroup='RM1',
            description_en='Current consumption exceeded in the relay channel 1',
            description_ru='Ток потребления превышен в радиоканале 1'
        ),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.ocb_states.link_0_ocb
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=29, name='RTR2OverCurrent',
            group='RM', subgroup='RM2',
            description_en='Current consumption exceeded in the relay channel 2',
            description_ru='Ток потребления превышен в радиоканале 2'
        ),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.ocb_states.link_1_ocb

    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=30, name='STR1OverCurrent',
            group='SM', subgroup='SM1',
            description_en='Current consumption exceeded in the service channel 1',
            description_ru='Ток потребления превышен в сервисном канале 1'
        ),
        block_state_only=False,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].ocb_in_work
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=31, name='STR2OverCurrent',
            group='SM', subgroup='SM2',
            description_en='Current consumption exceeded in the service channel 2',
            description_ru='Ток потребления превышен в сервисном канале 2'
        ),
        block_state_only=False,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].ocb_in_work
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=32, name='STR3OverCurrent',
            group='SM', subgroup='SM3',
            description_en='Current consumption exceeded in the service channel 3',
            description_ru='Ток потребления превышен в сервисном канале 3'
        ),
        block_state_only=False,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].ocb_in_work
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=33, name='STR4OverCurrent',
            group='SM', subgroup='SM4',
            description_en='Current consumption exceeded in the service channel 4',
            description_ru='Ток потребления превышен в сервисном канале 4'
        ),
        block_state_only=False,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].ocb_in_work
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=34, name='STROverCurrent5V',
            group='SM',
            description_en='Current consumption exceeded in the LNA channel',
            description_ru='Ток потребления превышен в канале МШУ'
        ),
        block_state_only=False,
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.ocb_states.service_5v_ocb
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=35, name='SensorInput1',
            group='Sens', subgroup='Sens1',
            description_en='Dry contact 1 is closed/open',
            description_ru='Сухой контакт 1 замкнут/разомкнут'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sensors[0].enabled,
        bounds=StrictBound(value=lambda ctx: ctx.full_unit_configuration.alarm_config.sensors[0].normal_state),
        reader=lambda ctx: ctx.technical_status.sensors[0]
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=36, name='SensorInput2',
            group='Sens', subgroup='Sens2',
            description_en='Dry contact 2 is closed/open',
            description_ru='Сухой контакт 2 замкнут/разомкнут'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sensors[1].enabled,
        bounds=StrictBound(value=lambda ctx: ctx.full_unit_configuration.alarm_config.sensors[1].normal_state),
        reader=lambda ctx: ctx.technical_status.sensors[1]
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=37, name='OpticalLink1Status',
            group='Optic', subgroup='Optic1',
            description_en='Connection via optical link 1 is lost',
            description_ru='Соединение через оптический канал 1 потеряно'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sfp[0],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.sfp_telemetry[0].rx_los
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=38, name='OpticalLink2Status',
            group='Optic', subgroup='Optic2',
            description_en='Connection via optical link 2 is lost',
            description_ru='Соединение через оптический канал 2 потеряно'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sfp[1],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.sfp_telemetry[1].rx_los
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=39, name='PWVoltage28V',
            group='Power',
            description_en='Voltage 28V power supply has gone beyond permissible limits',
            description_ru='Напряжение 28В на блоке питания вышло за допустимые пределы'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
        bounds=InRangeBounds(min=27.0, max=31.5),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.voltage28v
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=40, name='PWVoltage5V',
            group='Power',
            description_en='Voltage 5V power supply has gone beyond permissible limits',
            description_ru='Напряжение 5В на блоке питания вышло за допустимые пределы'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
        bounds=InRangeBounds(min=4.5, max=5.5),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.voltage5v
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=41, name='PWCurrent48V',
            group='Power',
            description_en='The current consumption at 48V in the power supply has been exceeded',
            description_ru='Ток потребления по 48В в блоке питания был превышен'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=23),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=InRangeBounds(min=0.0, max=10.0),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.current48v
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=42, name='PWCurrent28V',
            group='Power',
            description_en='The current consumption at 28V in the power supply has been exceeded',
            description_ru='Ток потребления по 28В в блоке питания был превышен'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=23),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=InRangeBounds(min=0.0, max=15.0),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.current28v
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=43, name='PWCurrent5V',
            group='Power',
            description_en='The current consumption at 5V in the power supply has been exceeded',
            description_ru='Ток потребления по 5В в блоке питания был превышен'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=23),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=InRangeBounds(min=0.0, max=8.0),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.current5v0
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=44, name='PWTemp',
            group='Power',
            description_en='The power supply temperature has gone beyond permissible limits',
            description_ru='Температура блока питания вышла за допустимые пределы'
        ),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=23),
        server_info=ServerAlarmInfo(actuation_count=33),
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.pwr_telemetry.temperature5v
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=45, name='DSPVoltageFPGA1V8',
            group='DSP',
            description_en='Voltage 1.8V FPGA has gone beyond permissible limits',
            description_ru='Напряжение 1.8В FPGA вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.6, max=2.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.fpga_1v8,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=46, name='DSPVoltageFPGA3V3',
            group='DSP',
            description_en='Voltage 3.3V FPGA has gone beyond permissible limits',
            description_ru='Напряжение 3.3В FPGA вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=3.0, max=3.6),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.fpga_3v3,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=47, name='DSPVoltageModem',
            group='DSP',
            description_en='Modem voltage level has gone beyond permissible limits',
            description_ru='Напряжение питания модема вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=3.0, max=4.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vbat_mpcie,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=48, name='DSPVoltageBatModem',
            group='DSP',
            description_en='Modem battery voltage level has gone beyond permissible limits',
            description_ru='Уровень напряжения батареи питания модема вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=4.7, max=5.4),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.cap_out_v,
        startup_timedelta=timedelta(minutes=5.1),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=49, name='DSPVoltageRTR1V3Synth',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 RadioLink has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Радиолинк вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc1_1v3_synth,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=50, name='DSPVoltageRTR1V3XCVR',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 RadioLink has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Радиолинк вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc1_1v3_xcvr,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=51, name='DSPVoltageRTR1V8',
            group='DSP',
            description_en='Voltage 1.8V at AD9361 RadioLink has gone beyond permissible limits',
            description_ru='Напряжение 1.8В на AD9361 Радиолинк вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.6, max=2.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc1_1v8,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=52, name='DSPVoltage1STR1V3Synth',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 Service 1 and 2 has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Сервис 1 и 2 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc2_1v3_synth,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=53, name='DSPVoltage1STR1V3XCVR',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 Service 1 and 2 has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Сервис 1 и 2 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc2_1v3_xcvr,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=54, name='DSPVoltage1STR1V8',
            group='DSP',
            description_en='Voltage 1.8V at AD9361 Service 1 and 2 has gone beyond permissible limits',
            description_ru='Напряжение 1.8В на AD9361 Сервис 1 и 2 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.6, max=2.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc2_1v8,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=55, name='DSPVoltage2STR1V3Synth',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 Service 3 and 4 has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Сервисный канал 3 и 4 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc3_1v3_synth,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=56, name='DSPVoltage2STR1V3XCVR',
            group='DSP',
            description_en='Voltage 1.3V at AD9361 Service 3 and 4 has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9361 Сервисный канал 3 и 4 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc3_1v3_xcvr,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=57, name='DSPVoltage2STR1V8',
            group='DSP',
            description_en='Voltage 1.8V at AD9361 Service 3 and 4 has gone beyond permissible limits',
            description_ru='Напряжение 1.8В на AD9361 Сервисный канал 3 и 4 вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.6, max=2.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc3_1v8,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=58, name='DSPVoltageDPD1V3Synth',
            group='DSP',
            description_en='Voltage 1.3V at AD9364 Power meter has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9364 Измеритель мощностей вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc4_1v3_synth,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=59, name='DSPVoltageDPD1V3XCVR',
            group='DSP',
            description_en='Voltage 1.3V at AD9364 Power meter has gone beyond permissible limits',
            description_ru='Напряжение 1.3В на AD9364 Измеритель мощностей вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.1, max=1.5),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc4_1v3_xcvr,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=60, name='DSPVoltageDPD1V8',
            group='DSP',
            description_en='Voltage 1.8V at AD9364 has gone beyond permissible limits',
            description_ru='Напряжение 1.8В на AD9364 Измеритель мощностей вышло за допустимые пределы'
        ),
        bounds=InRangeBounds(min=1.6, max=2.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.vdc4_1v8,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=61, name='DSPTemp40MHz',
            group='DSP',
            description_en='Temperature at the OCXO  has gone beyond permissible limits',
            description_ru='Температура опорного генератора OCXO 40 MHz вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_40mhz,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=62, name='Offset40MHzc',
            group='DSP',
            description_en='Frequency at the OCXO has gone beyond permissible limits',
            description_ru='Частота опорного генератора OCXO 40 MHz вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-220, max=220),
        reader=lambda ctx: TSValue[float](value=4e7 - ctx.technical_status.gps_telemetry.reference_freq_40mhz.value),
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=63, name='DSPTempFPGA',
            group='DSP',
            description_en='Temperature at the FPGA has gone beyond permissible limits',
            description_ru='Температура FPGA вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_fpga,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=64, name='DSPTempRTR',
            group='DSP',
            description_en='Temperature at the AD9361 – 1 RadioLink  has gone beyond permissible limits',
            description_ru='Температура AD9361 – 1 Радиолинк вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_link_ad9361,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=65, name='DSPTempSTR1',
            group='DSP',
            description_en='Temperature at the AD9361 – 2 Service channels 1 and 2 has gone beyond permissible limits',
            description_ru='Температура AD9361 – 2 Сервисный канал 1 и 2 вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_sv1_ad9361,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=66, name='DSPTempSTR2',
            group='DSP',
            description_en='Temperature at the AD9361 – 3 Service channels 3 and 4 has gone beyond permissible limits',
            description_ru='Температура AD9361 – 3 Сервисный канал 3 и 4 вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_sv2_ad9361,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=67, name='DSPTempDPD',
            group='DSP',
            description_en='Temperature at the AD9364 Power meters has gone beyond permissible limits',
            description_ru='Температура AD9364 Измеритель мощностей вышла за допустимые пределы'
        ),
        bounds=InRangeBounds(min=-40.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.dsp_telemetry.temperature_ad9364,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=68, name='DSPTempModem',
            group='DSP',
            description_en='Temperature at the Modem has gone beyond permissible limits',
            description_ru='Температура модема вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=69, name='STR1Temp',
            group='SM', subgroup='SM1',
            description_en='Temperature at 1st amplifier has gone beyond permissible limits',
            description_ru='Температура 1 усилителя вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].temperature,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=70, name='STR2Temp',
            group='SM', subgroup='SM2',
            description_en='Temperature at 2nd amplifier has gone beyond permissible limits',
            description_ru='Температура 2 усилителя вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].temperature,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=71, name='STR3Temp',
            group='SM', subgroup='SM3',
            description_en='Temperature at 3rd amplifier has gone beyond permissible limits',
            description_ru='Температура 3 усилителя вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].temperature,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=72, name='STR4Temp',
            group='SM', subgroup='SM4',
            description_en='Temperature at 4th amplifier has gone beyond permissible limits',
            description_ru='Температура 4 усилителя вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].temperature,
        actuation_count=2,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=73, name='STR1Voltage28V',
            group='SM', subgroup='SM1',
            description_en='Voltage 28V of 1st amplifier has gone beyond permissible limits',
            description_ru='Напряжение 28В 1 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=lambda ctx: 26.0 if ctx.full_unit_configuration.service_channels[0].type == ModuleType.LTE else 25.0,
            max=31.5
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=74, name='STR2Voltage28V',
            group='SM', subgroup='SM2',
            description_en='Voltage 28V of 2nd amplifier has gone beyond permissible limits',
            description_ru='Напряжение 28В 2 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=lambda ctx: 26.0 if ctx.full_unit_configuration.service_channels[1].type == ModuleType.LTE else 25.0,
            max=31.5
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=75, name='STR3Voltage28V',
            group='SM', subgroup='SM3',
            description_en='Voltage 28V of 3rd amplifier has gone beyond permissible limits',
            description_ru='Напряжение 28В 3 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=lambda ctx: 26.0 if ctx.full_unit_configuration.service_channels[2].type == ModuleType.LTE else 25.0,
            max=31.5
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=76, name='STR4Voltage28V',
            group='SM', subgroup='SM4',
            description_en='Voltage 28V of 4th amplifier has gone beyond permissible limits',
            description_ru='Напряжение 28В 4 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=lambda ctx: 26.0 if ctx.full_unit_configuration.service_channels[3].type == ModuleType.LTE else 25.0,
            max=31.5
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=77, name='STR1Voltage5V',
            group='SM', subgroup='SM1',
            description_en='Voltage 5V of 1st amplifier has gone beyond permissible limits',
            description_ru='Напряжение 5В 1 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=4.0, max=5.5),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].lna_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=78, name='STR2Voltage5V',
            group='SM', subgroup='SM2',
            description_en='Voltage 5V of 2nd amplifier has gone beyond permissible limits',
            description_ru='Напряжение 5В 2 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=4.0, max=5.5),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].lna_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=79, name='STR3Voltage5V',
            group='SM', subgroup='SM3',
            description_en='Voltage 5V of 3rd amplifier has gone beyond permissible limits',
            description_ru='Напряжение 5В 3 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=4.0, max=5.5),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].lna_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=80, name='STR4Voltage5V',
            group='SM', subgroup='SM4',
            description_en='Voltage 5V of 4th amplifier has gone beyond permissible limits',
            description_ru='Напряжение 5В 4 усилителя вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(min=4.0, max=5.5),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].lna_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=81, name='STR1Current28V',
            group='SM', subgroup='SM1',
            description_en='The current of 28V at 1st amplifier has gone beyond permissible limits',
            description_ru='Ток по 28В 1 усилителя вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[0].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=0.1,
            max=lambda ctx: 2.5 if ctx.full_unit_configuration.service_channels[0].type == ModuleType.LTE else 3.8
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[0].current_28v,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=82, name='STR2Current28V',
            group='SM', subgroup='SM2',
            description_en='The current of 28V at 2nd amplifier has gone beyond permissible limits',
            description_ru='Ток по 28В 2 усилителя вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=0.1,
            max=lambda ctx: 2.5 if ctx.full_unit_configuration.service_channels[1].type == ModuleType.LTE else 3.8
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[1].current_28v,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=83, name='STR3Current28V',
            group='SM', subgroup='SM3',
            description_en='The current of  28V at 3rd amplifier has gone beyond permissible limits',
            description_ru='Ток по 28В 3 усилителя вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[2].str.enabled and
            not ctx.technical_status.sm_telemetry[2].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=0.1,
            max=lambda ctx: 2.5 if ctx.full_unit_configuration.service_channels[2].type == ModuleType.LTE else 3.8
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[2].current_28v,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=84, name='STR4Current28V',
            group='SM', subgroup='SM4',
            description_en='The current of 28V at 4th amplifier has gone beyond permissible limits',
            description_ru='Ток по 28В 4 усилителя вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.service_channels[3].str.enabled and
            not ctx.technical_status.sm_telemetry[3].ocb_in_work.value,
        block_state_only=False,
        bounds=InRangeBounds(
            min=0.1,
            max=lambda ctx: 2.5 if ctx.full_unit_configuration.service_channels[3].type == ModuleType.LTE else 3.8
        ),
        reader=lambda ctx: ctx.technical_status.sm_telemetry[3].current_28v,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=57),
        server_info=ServerAlarmInfo(actuation_count=77)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=85, name='STR1Current5V',
            group='SM', subgroup='SM1',
            description_en='The current of  5V at 1st amplifier has gone beyond permissible limits',
            description_ru='Ток по 5В 1 усилителя вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=86, name='STR2Current5V',
            group='SM', subgroup='SM2',
            description_en='The current of  5V at 2nd amplifier has gone beyond permissible limits',
            description_ru='Ток по 5В 2 усилителя вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=87, name='STR3Current5V',
            group='SM', subgroup='SM3',
            description_en='The current of 5V at 3rd amplifier has gone beyond permissible limits',
            description_ru='Ток по 5В 3 усилителя вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=88, name='STR4Current5V',
            group='SM', subgroup='SM4',
            description_en='The current of 5V at 4th amplifier has gone beyond permissible limits',
            description_ru='Ток по 5В 4 усилителя вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=89, name='RTR1Voltage28V',
            group='RM', subgroup='RM1',
            description_en='Voltage 28V at 1st relay module has gone beyond permissible limits',
            description_ru='Напряжение 28В 1 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=26.0, max=31.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=90, name='RTR1Voltage7V',
            group='RM', subgroup='RM1',
            description_en='Voltage 7V at 1st relay module has gone beyond permissible limits',
            description_ru='Напряжение 7В 1 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=6.0, max=7.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].voltage_8v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=91, name='RTR1Voltage5V',
            group='RM', subgroup='RM1',
            description_en='Voltage 5V at 1st relay module has gone beyond permissible limits',
            description_ru='Напряжение 5В 1 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=4.5, max=5.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].voltage_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=92, name='RTR2Voltage28V',
            group='RM', subgroup='RM2',
            description_en='Voltage 28V at 2nd relay module has gone beyond permissible limits',
            description_ru='Напряжение 28В 2 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=26.0, max=31.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].voltage_28v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=93, name='RTR2Voltage7V',
            group='RM', subgroup='RM2',
            description_en='Voltage 7V at 2nd relay module has gone beyond permissible limits',
            description_ru='Напряжение 7В 2 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=6.0, max=7.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].voltage_8v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=94, name='RTR2Voltage5V',
            group='RM', subgroup='RM2',
            description_en='Voltage 5V at 2nd relay module has gone beyond permissible limits',
            description_ru='Напряжение 5В 2 релейного блока вышло за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=4.5, max=5.5),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].voltage_5v,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=95, name='RTR1Temp',
            group='RM', subgroup='RM1',
            description_en='Temperature at the 1st relay module has gone beyond permissible limits',
            description_ru='Температура 1 релейного блока вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].temperature,
        actuation_count=5,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=36)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=96, name='RTR2Temp',
            group='RM', subgroup='RM2',
            description_en='Temperature at the 2nd relay module has gone beyond permissible limits',
            description_ru='Температура 2 релейного блока вышла за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=-65.0, max=120.0),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].temperature
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=97, name='RTR1Current28V',
            group='RM', subgroup='RM1',
            description_en='The current of the 28V at 1 relay module’s current has gone beyond permissible limits',
            description_ru='Ток по 28В 1 релейного блока вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=0.3, max=1.7),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].current_rm_module,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=22),
        server_info=ServerAlarmInfo(actuation_count=33)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=98, name='RTR2Current28V',
            group='RM', subgroup='RM2',
            description_en='The current of the 28V at 2nd relay module’s current has gone beyond permissible limits',
            description_ru='Ток по 28В 2 релейного блока вышел за допустимые пределы'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=InRangeBounds(min=0.3, max=1.7),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].current_rm_module,
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=22),
        server_info=ServerAlarmInfo(actuation_count=33)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=99, name='RTR1LOLockTx',
            group='RM', subgroup='RM1',
            description_en='Reference frequency 40MHz of transmitter in the 1 relay module is lost',
            description_ru='Захват опорной частоты 40 MHz передатчика 1 релейного блока потерян'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].tx_synth_lock,
        actuation_count=11,
        user_info = UserAlarmInfo(actuation_count=155),
        server_info = ServerAlarmInfo(actuation_count=222)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=100, name='RTR2LOLockTx',
            group='RM', subgroup='RM2',
            description_en='Reference frequency 40MHz of transmitter in the 2 relay module is lost',
            description_ru='Захват опорной частоты 40 MHz передатчика 2 релейного блока потерян'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].tx_synth_lock,
        user_info=UserAlarmInfo(actuation_count=155),
        server_info=ServerAlarmInfo(actuation_count=222)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=101, name='RTR1LOLockRx',
            group='RM', subgroup='RM1',
            description_en='Reference frequency 40MHz of transmitter in the 1 relay module is lost',
            description_ru='Захват опорной частоты 40 MHz приемника 1 релейного блока потерян'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].rx_synth_lock,
        user_info=UserAlarmInfo(actuation_count=155),
        server_info=ServerAlarmInfo(actuation_count=222)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=102, name='RTR2LOLockRx',
            group='RM', subgroup='RM2',
            description_en='Reference frequency 40MHz of transmitter in the 2 relay module is lost',
            description_ru='Захват опорной частоты 40 MHz приемника 2 релейного блока потерян'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].rx_synth_lock,
        user_info=UserAlarmInfo(actuation_count=155),
        server_info=ServerAlarmInfo(actuation_count=222)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=103, name='ConnectionToServerLost',
            group='Modem',
            description_en='Server connection is lost',
            description_ru='Соединение с сервером потеряно',
            is_warning=True,
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.server_alarm,
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.statuses.server,
        user_info=UserAlarmInfo(actuation_count=66),
        server_info=ServerAlarmInfo(actuation_count=77),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=104, name='ModemMalfunction',
            group='Modem',
            description_en='Violation operability of GPRS/UMTS/HSPA/LTE modem',
            description_ru='Нарушение работоспособности модема GPRS/UMTS/HSPA/LTE'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.modem_alarm,
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.modem_no_work,
        user_info=UserAlarmInfo(actuation_count=80),
        server_info=ServerAlarmInfo(actuation_count=85),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=105, name='GPSFailure',
            group='GPS',
            description_en='Satellites connection is lost',
            description_ru='Подключение к спутникам потеряно',
            is_warning=True,
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.gps_telemetry.status,
        actuation_count=32,
        user_info=UserAlarmInfo(actuation_count=29_600),
        server_info=ServerAlarmInfo(actuation_count=29_600),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=106, name='SFP1ModuleInsert',
            group='Optic', subgroup='Optic1',
            description_en='The optical link 1 SFP+ module is inserted',
            description_ru='SFP+ модуль оптического линка 1 не установлен'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sfp[0],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.sfp_telemetry[0].mod_abs
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=107, name='SFP2ModuleInsert',
            group='Optic', subgroup='Optic2',
            description_en='The optical link 2 SFP+ module is inserted',
            description_ru='SFP+ модуль оптического линка 2 не установлен'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.sfp[1],
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.sfp_telemetry[1].mod_abs
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=108, name='PowerFailure',
            group='Power',
            description_en='Supply voltage is lost',
            description_ru='Напряжение питания потеряно'
        )
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=109, name='TxLink1LoopOverAttenuation',
            group='RM', subgroup='RM1',
            description_en='Radio channel 1 cannot reach the set output power in automatic control',
            description_ru='Радиоканал 1 не может достичь заданной выходной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_tx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=42)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=110, name='TxLink1CalibrateRmIsNotOk',
            group='RM', subgroup='RM1',
            description_en='Calibration of radio channel 1 failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка радиоканала 1 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=111, name='TxLink1CalibratePowerNotReached',
            group='RM', subgroup='RM1',
            description_en='Calibration of radio channel 1 failed - the specified output power was not reached',
            description_ru='Калибровка радиоканала 1 не прошла - не достигнута заданная выходная мощность'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=112, name='TxLink2LoopOverAttenuation',
            group='RM', subgroup='RM2',
            description_en='Radio channel 2 cannot reach the set output power in automatic control',
            description_ru='Радиоканал 2 не может достичь заданной выходной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_tx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        actuation_count=3,
        user_info=UserAlarmInfo(actuation_count=26),
        server_info=ServerAlarmInfo(actuation_count=42),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=113, name='TxLink2CalibrateRmIsNotOk',
            group='RM', subgroup='RM2',
            description_en='Calibration of radio channel 2 failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка радиоканала 2 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=114, name='TxLink2CalibratePowerNotReached',
            group='RM', subgroup='RM2',
            description_en='Calibration of radio channel 2 failed - the specified output power was not reached',
            description_ru='Калибровка радиоканала 2 не прошла - не достигнута заданная выходная мощность'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=115, name='RxLink1LoopOverGain',
            group='RM', subgroup='RM1',
            description_en='Radio channel 1 cannot reach the specified input power in automatic control',
            description_ru='Радиоканал 1 не может достичь заданной входной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_rx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        actuation_count=6,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=45)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=116, name='RxLink2LoopOverGain',
            group='RM', subgroup='RM2',
            description_en='Radio channel 2 cannot reach the specified input power in automatic control',
            description_ru='Радиоканал 2 не может достичь заданной входной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_link_rx and
            ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        actuation_count=6,
        user_info=UserAlarmInfo(actuation_count=33),
        server_info=ServerAlarmInfo(actuation_count=45)
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=117, name='TxService1LoopOverAttenuation',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 1 не может достичь заданной выходной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[0].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=7),
        server_info=ServerAlarmInfo(actuation_count=9),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=118, name='TxService1CalibrateSmIsNotOk',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 calibration failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка сервисного канала 1 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=119, name='TxService1CalibrateOverAttenuation',
            group='SM', subgroup='SM1',
            description_en='Calibration of the service channel 1 did not pass - the specified output power was not reached (the AD gain coefficient was not enough)',
            description_ru='Калибровка сервисного канала 1 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=120, name='TxService1CalibratePowerNotReached',
            group='SM', subgroup='SM1',
            description_en='Calibration of the service channel 1 failed - the machine incorrectly calculated the AD gain',
            description_ru='Калибровка сервисного канала 1 не прошла - автомат неверно рассчитал коэффициент усиления AD'
        ),
    ),

    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=121, name='TxService2LoopOverAttenuation',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 2 не может достичь заданной выходной мощности в автоматическом регулировании'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[1].str.enabled and
            not ctx.technical_status.sm_telemetry[1].ocb_in_work.value,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=7),
        server_info=ServerAlarmInfo(actuation_count=9),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=122, name='TxService1CalibrateSmIsNotOk',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 calibration failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка сервисного канала 2 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=123, name='TxService2CalibrateOverAttenuation',
            group='SM', subgroup='SM2',
            description_en='Calibration of the service channel 2 did not pass - the specified output power was not reached (the AD gain coefficient was not enough)',
            description_ru='Калибровка сервисного канала 2 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=124, name='TxService2CalibratePowerNotReached',
            group='SM', subgroup='SM2',
            description_en='Calibration of the service channel 2 failed - the machine incorrectly calculated the AD gain',
            description_ru='Калибровка сервисного канала 2 не прошла - автомат неверно рассчитал коэффициент усиления AD'
        ),
    ),

    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=125, name='TxService3LoopOverAttenuation',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 3 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[2].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=7),
        server_info=ServerAlarmInfo(actuation_count=9),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=126, name='TxService3CalibrateSmIsNotOk',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 calibration failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка сервисного канала 3 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=127, name='TxService3CalibrateOverAttenuation',
            group='SM', subgroup='SM3',
            description_en='Calibration of the service channel 3 did not pass - the specified output power was not reached (the AD gain coefficient was not enough)',
            description_ru='Калибровка сервисного канала 3 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=128, name='TxService3CalibratePowerNotReached',
            group='SM', subgroup='SM3',
            description_en='Calibration of the service channel 3 failed - the machine incorrectly calculated the AD gain',
            description_ru='Калибровка сервисного канала 3 не прошла - автомат неверно рассчитал коэффициент усиления AD'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=129, name='TxService4LoopOverAttenuation',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 4 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[3].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=7),
        server_info=ServerAlarmInfo(actuation_count=6),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=130, name='TxService4CalibrateSmIsNotOk',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 calibration failed - module voltage parameters are out of acceptable limits',
            description_ru='Калибровка сервисного канала 4 не прошла - параметры напряжений модуля вне допустимых пределов'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=131, name='TxService4CalibrateOverAttenuation',
            group='SM', subgroup='SM4',
            description_en='Calibration of the service channel 4 did not pass - the specified output power was not reached (the AD gain coefficient was not enough)',
            description_ru='Калибровка сервисного канала 4 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=132, name='TxService4CalibratePowerNotReached',
            group='SM', subgroup='SM4',
            description_en='Calibration of the service channel 4 failed - the machine incorrectly calculated the AD gain',
            description_ru='Калибровка сервисного канала 4 не прошла - автомат неверно рассчитал коэффициент усиления AD'
        ),
    ),

    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=133, name='RTR1PilotRxLose',
            group='RM', subgroup='RM1',
            description_en='Radio channel 1 - input pilot signal lost',
            description_ru='Радиоканал 1 - потерян входной пилот сигнал',
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=StrictBound(value=lambda ctx: True),
        actuation_count=48,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].pilots_power_rx_link_status,
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=134, name='RTR2PilotRxLose',
            group='RM', subgroup='RM2',
            description_en='Radio channel 2 - input pilot signal lost',
            description_ru='Радиоканал 2 - потерян входной пилот сигнал',
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=StrictBound(value=lambda ctx: True),
        actuation_count=48,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].pilots_power_rx_link_status,
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=135, name='RTR1PilotTxLose',
            group='RM', subgroup='RM1',
            description_en='Radio channel 1 - output pilot signal lost',
            description_ru='Радиоканал 1 - потерян выходной пилот сигнал'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=StrictBound(value=lambda ctx: True),
        actuation_count=16,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].pilots_power_tx_link_status
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=136, name='RTR2PilotTxLose',
            group='RM', subgroup='RM2',
            description_en='Radio channel 2 - output pilot signal lost',
            description_ru='Радиоканал 2 - потерян выходной пилот сигнал'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=StrictBound(value=lambda ctx: True),
        actuation_count=16,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[1].pilots_power_tx_link_status
    ),

    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=137, name='TxLink1CalibrateOverAttenuation',
            group='RM', subgroup='RM1',
            description_en='Calibration of radio channel 1 failed - the specified output power was not reached (AD power factor inaccuracies)',
            description_ru='Калибровка радиоканал 1 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=138, name='TxLink2CalibrateOverAttenuation',
            group='RM', subgroup='RM2',
            description_en='Calibration of radio channel 2 failed - the specified output power was not reached (AD power factor inaccuracies)',
            description_ru='Калибровка радиоканал 2 не прошла - не достигнута заданная выходная мощность(недостаточно коэффициента усиления AD)'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=139, name='TxLink1CalibrateLinkLos',
            group='RM', subgroup='RM1',
            description_en='Calibration of radio channel 1 failed - pilot signal lost',
            description_ru='Калибровка радиоканал 1 не прошла - потерян пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=140, name='TxLink2CalibrateLinkLos',
            group='RM', subgroup='RM2',
            description_en='Calibration of radio channel 2 failed - pilot signal lost',
            description_ru='Калибровка радиоканал 2 не прошла - потерян пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=141, name='RTR1InputPilotPowerFsr',
            group='RM', subgroup='RM1',
            description_en='The pilot-signal power level has gone beyond permissible limits in the relay channel 1',
            description_ru='Уровень принимаемой мощности пилот-сигнала вышел за допустимые пределы в радиоканале 1',
        ),
        block_state_only=False,
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0],
        bounds=InRangeBounds(min=38.0-2, max=38.0+2),
        actuation_count=48,
        user_info=UserAlarmInfo(actuation_count=333),
        server_info=ServerAlarmInfo(actuation_count=355),
        reader=lambda ctx: ctx.technical_status.rm_telemetry[0].pilots_power_rx,
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=142, name='SM1PowerCalcFailed',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 calibration failed - internal pilot signal not calibrated',
            description_ru='Калибровка сервисного канала 1 не прошла - не откалиброван внутренний пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=143, name='SM2PowerCalcFailed',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 calibration failed - internal pilot signal not calibrated',
            description_ru='Калибровка сервисного канала 2 не прошла - не откалиброван внутренний пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=144, name='SM3PowerCalcFailed',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 calibration failed - internal pilot signal not calibrated',
            description_ru='Калибровка сервисного канала 3 не прошла - не откалиброван внутренний пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=145, name='SM4PowerCalcFailed',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 calibration failed - internal pilot signal not calibrated',
            description_ru='Калибровка сервисного канала 4 не прошла - не откалиброван внутренний пилот сигнал'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=146, name='ModemNoSim',
            group='Modem',
            description_en='Violation operability of GPRS/UMTS/HSPA/LTE modem: no sim card',
            description_ru='Нарушение работоспособности модема GPRS/UMTS/HSPA/LTE: нет сим карты'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.alarm_config.modem_alarm,
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.modem_no_sim,
        # for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=147, name='TxService1LoopOverAttenuationGSM',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 1 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[0].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=36),
        server_info=ServerAlarmInfo(actuation_count=36 ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=148, name='TxService2LoopOverAttenuationGSM',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 2 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[1].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=36),
        server_info=ServerAlarmInfo(actuation_count=36),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=149, name='TxService3LoopOverAttenuationGSM',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 3 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[2].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=77),
        server_info=ServerAlarmInfo(actuation_count=88),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=150, name='TxService4LoopOverAttenuationGSM',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 cannot reach the set output power in automatic control',
            description_ru='Сервисный канал 4 не может достичь заданной выходной мощности в автоматическом управлении'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.unit_configuration.ac_service_tx and
            ctx.full_unit_configuration.service_channels[3].str.enabled,
        actuation_count=1,
        user_info=UserAlarmInfo(actuation_count=77),
        server_info=ServerAlarmInfo(actuation_count=88),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=151, name='RTR1VSWRCriticalOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: VSWR is critical',
            description_ru='Выключение питания в радиоканале 1: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=152, name='RTR2VSWRCriticalOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: VSWR is critical',
            description_ru='Выключение питания в радиоканале 2: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=153, name='RTR1OverCurrentOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: current consumption exceeded',
            description_ru='Выключение питания в радиоканале 1: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=154, name='RTR2OverCurrentOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: current consumption exceeded',
            description_ru='Выключение питания в радиоканале 2: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=155, name='RTR1Voltage28VOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 1: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=156, name='RTR2Voltage28VOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 2: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=157, name='RTR1Voltage7VOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: voltage 7V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 1: напряжение 7В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=158, name='RTR2Voltage7VOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: voltage 7V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 2: напряжение 7В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=159, name='RTR1Voltage5VOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 1: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=160, name='RTR2Voltage5VOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 2: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=161, name='RTR1TempOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 1: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=162, name='RTR2TempOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 2: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=163, name='RTR1Current28VOnPowerOn',
            group='RM', subgroup='RM1',
            description_en='Relay channel 1 power off: the current of the 28V current has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 1: ток по 28В вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=164, name='RTR2Current28VOnPowerOn',
            group='RM', subgroup='RM2',
            description_en='Relay channel 2 power off: the current of the 28V current has gone beyond permissible limits',
            description_ru='Выключение питания в радиоканале 2: ток по 28В вышел за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=165, name='STR1VSWROnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: VSWR has exceed',
            description_ru='Выключение питания в сервисном канале 1: превышено значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=166, name='STR2VSWROnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: VSWR has exceed',
            description_ru='Выключение питания в сервисном канале 2: превышено значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=167, name='STR3VSWROnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: VSWR has exceed',
            description_ru='Выключение питания в сервисном канале 3: превышено значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=168, name='STR4VSWROnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: VSWR has exceed',
            description_ru='Выключение питания в сервисном канале 4: превышено значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=169, name='STR1VSWRCriticalOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: VSWR is critical',
            description_ru='Выключение питания в сервисном канале 1: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=170, name='STR2VSWRCriticalOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: VSWR is critical',
            description_ru='Выключение питания в сервисном канале 2: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=171, name='STR3VSWRCriticalOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: VSWR is critical',
            description_ru='Выключение питания в сервисном канале 3: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=172, name='STR4VSWRCriticalOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: VSWR is critical',
            description_ru='Выключение питания в сервисном канале 4: критическое значение КСВ'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=173, name='STR1OverCurrentOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: current consumption exceeded',
            description_ru='Выключение питания в сервисном канале 1: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=174, name='STR2OverCurrentOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: current consumption exceeded',
            description_ru='Выключение питания в сервисном канале 2: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=175, name='STR3OverCurrentOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: current consumption exceeded',
            description_ru='Выключение питания в сервисном канале 3: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=176, name='STR4OverCurrentOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: current consumption exceeded',
            description_ru='Выключение питания в сервисном канале 4: превышен ток потребления'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=177, name='STR1TempOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 1: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=178, name='STR2TempOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 2: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=179, name='STR3TempOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 3: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=180, name='STR4TempOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: temperature has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 4: температура вышла за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=181, name='STR1Voltage28VOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 1: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=182, name='STR2Voltage28VOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 2: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=183, name='STR3Voltage28VOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 3: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=184, name='STR4Voltage28VOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: voltage 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 4: напряжение 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=185, name='STR1Voltage5VOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 1: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=186, name='STR2Voltage5VOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 2: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=187, name='STR3Voltage5VOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 3: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=188, name='STR4Voltage5VOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: voltage 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 4: напряжение 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=189, name='STR1Current28VOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: the current of 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 1: ток по 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=190, name='STR2Current28VOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: the current of 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 2: ток по 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=191, name='STR3Current28VOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: the current of 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 3: ток по 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=192, name='STR4Current28VOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: the current of 28V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 4: ток по 28В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=193, name='STR1Current5VOnPowerOn',
            group='SM', subgroup='SM1',
            description_en='Service channel 1 power off: the current of 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 1: ток по 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=194, name='STR2Current5VOnPowerOn',
            group='SM', subgroup='SM2',
            description_en='Service channel 2 power off: the current of 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 2: ток по 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=195, name='STR3Current5VOnPowerOn',
            group='SM', subgroup='SM3',
            description_en='Service channel 3 power off: the current of 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 3: ток по 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=196, name='STR4Current28VOnPowerOn',
            group='SM', subgroup='SM4',
            description_en='Service channel 4 power off: the current of 5V has gone beyond permissible limits',
            description_ru='Выключение питания в сервисном канале 4: ток по 5В вышло за допустимые пределы'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=197, name='TestInfoAlarm',
            group='Info', subgroup='Info',
            description_en='Test message for test alarm info system',
            description_ru='Тестовое сообщение, для теста систему информационных аварий'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=198, name='DigitalTune',
            group='Info', subgroup='Info',
            description_en='Digital tune preformed',
            description_ru='Произошла цифровая калибровка'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=199, name='ServiceTx1Skipped',
            group='Info', subgroup='Info',
            description_en='Service tx 1 automatic control operation is skipped, ocb is working',
            description_ru='Работа автомата service tx 1 пропущена, работает ocb'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=200, name='ServiceTx2Skipped',
            group='Info', subgroup='Info',
            description_en='Service tx 2 automatic control operation is skipped, ocb is working',
            description_ru='Работа автомата service tx 2 пропущена, работает ocb'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=201, name='ServiceTx3Skipped',
            group='Info', subgroup='Info',
            description_en='Service tx 3 automatic control operation is skipped, ocb is working',
            description_ru='Работа автомата service tx 3 пропущена, работает ocb'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=202, name='ServiceTx4Skipped',
            group='Info', subgroup='Info',
            description_en='Service tx 4 automatic control operation is skipped, ocb is working',
            description_ru='Работа автомата service tx 4 пропущена, работает ocb'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=203, name='OcbWorkRelay1',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in radio channel 1 has been triggered: the radio module will be rebooted',
            description_ru='Сработал автомат превышения тока в радиоканале 1: радиомодуль будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=204, name='OcbWorkRelay2',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in radio channel 2 has been triggered: the radio module will be rebooted',
            description_ru='Сработал автомат превышения тока в радиоканале 2: радиомодуль будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=205, name='OcbWorkSm1',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in service channel 1 has been triggered: the service will be rebooted',
            description_ru='Сработал автомат превышения тока в сервисном канале 1: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=206, name='OcbWorkSm2',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in service channel 2 has been triggered: the service will be rebooted',
            description_ru='Сработал автомат превышения тока в сервисном канале 2: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=207, name='OcbWorkSm3',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in service channel 3 has been triggered: the service will be rebooted',
            description_ru='Сработал автомат превышения тока в сервисном канале 3: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=208, name='OcbWorkSm4',
            group='Info', subgroup='Info',
            description_en='Overcurrent circuit breaker in service channel 4 has been triggered: the service will be rebooted',
            description_ru='Сработал автомат превышения тока в сервисном канале 4: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=209, name='ModemMalfunctionReboot',
            group='Info', subgroup='Info',
            description_en='Long-term modem failure: unit will reboot',
            description_ru='Продолжительная неисправность модема: блок будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=210, name='Sm1InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings on amplifier 1: the amplifier will reset',
            description_ru='Низкие показания напряжения на усилителе 1: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=211, name='Sm2InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings on amplifier 2: the amplifier will reset',
            description_ru='Низкие показания напряжения на усилителе 2: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=212, name='Sm3InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings on amplifier 3: the amplifier will reset',
            description_ru='Низкие показания напряжения на усилителе 3: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=213, name='Sm4InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings on amplifier 4: the amplifier will reset',
            description_ru='Низкие показания напряжения на усилителе 4: усилитель будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=214, name='UnfoundedGpsPosition',
            group='GPS',
            description_en='Missing gps configuration file',
            description_ru='Отсутствует файл конфигурации gps'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=215, name='InvalidGpsPosition',
            group='GPS',
            description_en='Invalid gps configuration file',
            description_ru='Не корректный файл конфигурации gps'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=216, name='DigitalTuneReboot',
            group='Info', subgroup='Info',
            description_en='Number of digital calibrations in time period exceeded: unit will be rebooted',
            description_ru='Превышено число цифровых калибровка в периоде времени: блок будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=217, name='BSSync',
            group='GPS',
            description_en='No synchronization with the Base Station',
            description_ru='Отсутствует синхронизация с Базовой станцией',
            is_warning=True,
        ),
        bounds=StrictBound(value=lambda ctx: True),
        reader=lambda ctx: ctx.technical_status.gps_telemetry.bs_sync,
        actuation_count=600,
        user_info=UserAlarmInfo(actuation_count=29_600),
        server_info=ServerAlarmInfo(actuation_count=29_600),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=218, name='ModemMalfunctionRebootUsb',
            group='Info', subgroup='Info',
            description_en='No modem bus: unit will reboot',
            description_ru='Отсутствие шины модема: блок будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=219, name='AD9361EqInvalid0',
            group='DSP',
            description_en='AD9361 №0 Broke: Works Like a Thumb',
            description_ru='Сломалась AD9361 №0: работает палец в небо'
        ),
        enabled=lambda ctx: ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[0] or ctx.full_unit_configuration.relay_channels[1].rtr_common.rt_rxs_enabled[1],
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_1_invalid,
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=220, name='AD9361EqInvalid1',
            group='DSP',
            description_en='AD9361 №1 Broke: Works Like a Thumb',
            description_ru='Сломалась AD9361 №1: работает палец в небо'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[0].str.enabled or ctx.full_unit_configuration.service_channels[1].str.enabled,
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_2_invalid,
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=221, name='AD9361EqInvalid2',
            group='DSP',
            description_en='AD9361 №2 Broke: Works Like a Thumb',
            description_ru='Сломалась AD9361 №2: работает палец в небо'
        ),
        enabled=lambda ctx:
            ctx.full_unit_configuration.service_channels[2].str.enabled or ctx.full_unit_configuration.service_channels[3].str.enabled,
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.ad9361_3_invalid,
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=222, name='AD9364EqInvalid',
            group='DSP',
            description_en='AD9364 Broke: Works Like a Thumb',
            description_ru='Сломалась AD9364: работает палец в небо'
        ),
        bounds=StrictBound(value=lambda ctx: False),
        reader=lambda ctx: ctx.technical_status.statuses.ad9364_invalid,
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=223, name='DigitalTuneD0',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №1 occurred: 1st radio-module malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №1: Не исправность 1-го радио-модуля'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=224, name='DigitalTuneD1',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №1 occurred: 2st radio-module malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №1: Не исправность 2-го радио-модуля'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=225, name='DigitalTuneD2',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №2 occurred: 1st amplifier malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №2: Не исправность 1-го усилителя'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=226, name='DigitalTuneD3',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №2 occurred: 2st amplifier malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №2: Не исправность 2-го усилителя'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=227, name='DigitalTuneD4',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №3 occurred: 3st amplifier malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №3: Не исправность 3-го усилителя'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=228, name='DigitalTuneD5',
            group='Info', subgroup='Info',
            description_en='Digital calibration ad9361 №3 occurred: 4st amplifier malfunction',
            description_ru='Произошла цифровая калибровка ad9361 №3: Не исправность 4-го усилителя'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=229, name='Rm1InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings in radio channel 1: the radio channel will reset',
            description_ru='Низкие показания напряжения в радиоканале 1: радиоканал будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=230, name='Rm2InvalidTelemetry',
            group='Info', subgroup='Info',
            description_en='Low voltage readings in radio channel 2: the radio channel will reset',
            description_ru='Низкие показания напряжения в радиоканале 2: радиоканал будет перезагружен'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=231, name='FaultBistTimingAnalysisD0',
            group='Info', subgroup='Info',
            description_en='Fault Bist Timing Analysis on AD9361 №1',
            description_ru='Неисправность Bist Timing Analysis на AD9361 №1'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=232, name='FaultBistTimingAnalysisD1',
            group='Info', subgroup='Info',
            description_en='Fault Bist Timing Analysis on AD9361 №2',
            description_ru='Неисправность Bist Timing Analysis на AD9361 №2'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=233, name='FaultBistTimingAnalysisD2',
            group='Info', subgroup='Info',
            description_en='Fault Bist Timing Analysis on AD9361 №3',
            description_ru='Неисправность Bist Timing Analysis на AD9361 №3'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=234, name='FaultBistTimingAnalysisD3',
            group='Info', subgroup='Info',
            description_en='Fault Bist Timing Analysis on AD9364',
            description_ru='Неисправность Bist Timing Analysis на AD9364'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=235, name='UserPowerReboot',
            group='Info', subgroup='Info',
            description_en='The user rebooted the power supply',
            description_ru='Пользователь перезагрузил блок по питанию'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=236, name='UserSoftReboot',
            group='Info', subgroup='Info',
            description_en='The user has rebooted the software unit',
            description_ru='Пользователь перезагрузил блок по софту'
        ),
        for_all_users=False
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=237, name='UserUpdatedBlock',
            group='Info', subgroup='Info',
            description_en='Block was updated by user',
            description_ru='Пользователь обновил блок'
        ),
    ),
    AlarmInfo(
        alarm_code_description=AlarmDescription(
            code=238, name='BlockCalibrated',
            group='Info', subgroup='Info',
            description_en='Block was calibrated by user',
            description_ru='Пользователь откалибровал блок'
        ),
    ),
]

ALARM_CODE_BY_NAME = {alarm.alarm_code_description.name: alarm.alarm_code_description.code for alarm in ALARMS}
ALARM_NAME_BY_CODE = {alarm.alarm_code_description.code: alarm.alarm_code_description.name for alarm in ALARMS}


def alarm_off_scams(ctx: AlarmsContext, alarm_code: int):
    if alarm_code == 79:
        if ctx.full_unit_configuration.unit_configuration.main_module.serial_number in ['003-03 230612']:
            return True
    elif alarm_code == 75:
        if ctx.full_unit_configuration.unit_configuration.main_module.serial_number in ['003-03 230612']:
            return True
    elif alarm_code == 83:
        if ctx.full_unit_configuration.unit_configuration.main_module.serial_number in ['003-03 2303 5']:
            return True

    return False




